<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="css/style.css"/>
		<style type="text/css">
			body{background: #fff;}	 
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		    <h1 class="mui-title"></h1>
		</header>
		<div class="mui-content mui-content-form">
			<h3 class="mui-text-center" style="padding: 30px 0;">注册帐号</h3>
			<form class="mui-input-group mui-margin-top">
				<div class="mui-input-row authCode">
					<input id='MobileNo' type="tel" oninput="if(value.length>13)value=value.slice(0,13)" onkeyup="formatMobile(this)" class="mui-input-clear mui-input" placeholder="您的手机号">
						<button type="button" id="btnSendAuthCode" class="mui-btn-mini" data-type="注册帐号" data-check="1">发送验证码</button>
				</div>
				<div class="mui-input-row">
					<input id='AuthCode' type="number" class="mui-input-clear mui-input" placeholder="请输入短信验证码">
				</div>
				<div class="mui-input-row">
					<input id='Password' type="password" class="mui-input-clear mui-input" placeholder="请输入登录密码">
				</div>
			</form>
			<div class="mui-content-padded pt-10">
				<button id='submit' class="mui-btn mui-btn-block mui-btn-danger">确定注册</button>
			</div>
		</div>
		<div class="pt-10">
			<h6 class="mui-content-padded mui-text-center">			
				注册/登录即代表同意<a href="javascript:void(0);" id="btnServiceTerms">用户使用协议</a>
			</h6>			
		</div>
		<script src="js/mui.min.js"></script>
		<script src="js/app.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			mui.init();
			
			var $MobileNo = document.getElementById("MobileNo");
			var $Password = document.getElementById("Password");
			var $AuthCode = document.getElementById("AuthCode");
			
			document.getElementById("btnServiceTerms").addEventListener('tap', function () {
				 openExternalLinks("服务条款", app.server + "/app/ServiceTerms.html", "ServiceTerms");
			})
			
			document.getElementById("submit").addEventListener('tap', function () {
				var mobile = $MobileNo.value.replace(/\s/g,"");
				var password = $Password.value;
				var authCode = $AuthCode.value;
				
				if(!checkMobile(mobile)){
					return;
				}
				
				if(password == ""){
					mui.toast("请输入登录密码");
					return;
				}
				if(authCode == ""){
					mui.toast("请输入验证码");
					return;
				}
				 
				mui.showLoading();
				var wv = plus.webview.currentWebview();
				app.post("Register", {Mobile:mobile, Password:password, AuthCode:authCode}, function (data) {
					if(data.isSuccess) {
						mui.toast("注册成功");
						app.loginCallback(data, function () {
							setTimeout(function () {
								wv.close("none");	
							},500);
							var launch = plus.webview.getLaunchWebview(); 
							launch.evalJS("refresh(true)"); 
							launch.show();
						});						
					} else {
						mui.toast(data.message);
					}
				})
			});
		</script> 
	</body>

</html>